import request from '@neu/biz-core/utils/request'
const baseUrl = 'dcom/api/w/alter'

export const create = (data) => {
  return request({
    url: baseUrl + '/applyform',
    data,
    method: 'post'
  })
}

export const detail = (workOrderNum, taskId) => {
  return request({
    url: baseUrl + '/applyform/' + workOrderNum + '/' + taskId,
    method: 'get'
  })
}

export const applyformDownloadFile = (fsId) => {
  return request({
    url: baseUrl + '/applyform/download/annex/' + fsId,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}

export const applyformImportUrl = baseUrl + '/applyform/upload/annex'

export const applyformDeleteAnnexByFsId = (fsId) => {
  return request({
    url: baseUrl + '/applyform/annex/' + fsId,
    method: 'delete'
  })
}

export const frontlineProcessingCreate = (data) => {
  return request({
    url: baseUrl + '/frontlineProcessingForm',
    data,
    method: 'post'
  })
}

export const frontlineProcessingDetail = (workOrderNum, taskId) => {
  return request({
    url: baseUrl + '/frontlineProcessingForm/' + workOrderNum + '/' + taskId,
    method: 'get'
  })
}

export const leaderApprovalCreate = (data) => {
  return request({
    url: baseUrl + '/leaderapproval',
    data,
    method: 'post'
  })
}

export const leaderApprovalDetail = (workOrderNum, taskId) => {
  return request({
    url: baseUrl + '/leaderapproval/' + workOrderNum + '/' + taskId,
    method: 'get'
  })
}

export const secondLeaderCreate = (data) => {
  return request({
    url: baseUrl + '/secondLeader',
    data,
    method: 'post'
  })
}

export const secondLeaderDetail = (workOrderNum, taskId) => {
  return request({
    url: baseUrl + '/secondLeader/' + workOrderNum + '/' + taskId,
    method: 'get'
  })
}

export const customerReviewCreate = (data) => {
  return request({
    url: baseUrl + '/customerreview',
    data,
    method: 'post'
  })
}

export const customerReviewDetail = (workOrderNum, taskId) => {
  return request({
    url: baseUrl + '/customerreview/' + workOrderNum + '/' + taskId,
    method: 'get'
  })
}

export const secondLineCreate = (data, flag) => {
  return request({
    url: baseUrl + '/secondLine/' + flag,
    data,
    method: 'post'
  })
}

export const secondLineDetail = (workOrderNum, taskId) => {
  return request({
    url: baseUrl + '/secondLine/' + workOrderNum + '/' + taskId,
    method: 'get'
  })
}

export const countersignatureCreate = (data) => {
  return request({
    url: baseUrl + '/countersignature',
    data,
    method: 'post'
  })
}

export const countersignatureDetail = (workOrderNum, taskId) => {
  return request({
    url: baseUrl + '/countersignature/' + workOrderNum + '/' + taskId,
    method: 'get'
  })
}

export const customerReviewDownloadFile = (fsId) => {
  return request({
    url: baseUrl + '/customerreview/download/annex/' + fsId,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}

export const customerReviewImportUrl = baseUrl + '/customerreview/upload/annex'

export const customerReviewDeleteAnnexByFsId = (fsId) => {
  return request({
    url: baseUrl + '/customerreview/annex/' + fsId,
    method: 'delete'
  })
}

export const auditHandleMalfunctionNum = () => {
  return request({
    url: baseUrl + '/audit/handle',
    method: 'get'
  })
}

export const auditCoSponsorMalfunctionNum = () => {
  return request({
    url: baseUrl + '/audit/sponsor',
    method: 'get'
  })
}

export const report = (params) => {
  return request({
    url: baseUrl + '/stats/report',
    params,
    method: 'get'
  })
}

export const exportReport = (params) => {
  return request({
    url: baseUrl + '/stats/export',
    params,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}

export const download = (workNum) => {
  return request({
    url: baseUrl + '/export/' + workNum,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  })
}
